
    library(brm)
    source("basics.R")
    source("1.1 CallMLEIte.R"); source("1.2 CallDR.R")
    
    # load data
    load("sample-data.RData")
    # Z: instrument
    # D: treatment
    # Y: outcome
    # X: covariates
    
    # Get the maximum likelihood estimate
    mle = MLEst(Z,D,Y,X, X.phi = X, target = "LATE")$val
    # X: the covariates used for the target model theta
    # X.phi: the covariates used for the nuisance models phi
    # target: can be "LATE" or "MLATE"
    
    # Get the efficient doubly robust estimate
    drw.bth = DREst(Z,D,Y,X, X.phi = X, X.pi = X, target = "LATE", optimal = TRUE, mle)$val
    # X.pi: the covariates used for the model for instrumental propensity score f(Z|X)
    
    # Get the unweighted (not necessarily efficient) doubly robust estimate
    dru.bth = DREst(Z,D,Y,X, X.phi = X, X.pi = X, target = "LATE", optimal = FALSE, mle)$val
    
    
        
    
        

    
    
    